package cn.zhb.backend.core.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/***
 *@Description
 *@Author ZHB
 *@Create 2025/7/3 下午4:21
 **/
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@Entity
@Table(name = "bus_category")
@TableName("bus_category")
@ApiModel("分类")
public class Category extends BaseEntity{

    @ApiModelProperty("类名")
    @Column(name = "name", nullable = false)
    @TableField(value = "name")
    private String name;

    @ApiModelProperty("上级分类ID")
    @Column(name = "parentId")
    @TableField(value = "parentId")
    private Long parentId;

    // 一对多：一个分类包含多个题目
    @OneToMany(mappedBy = "category", cascade = CascadeType.ALL, orphanRemoval = true)
    @TableField(exist = false)
    private List<Question> questions = new ArrayList<>();

}
